Some history: Wilson and Lagrange

Here I have to move quickly (in fact I'll simply have to fly through this section), and attempt not to get too involved in covering standard material (of a type that I covered last November 2004 with my 2nd year BEd and BA students).

The essential point about Wilson and Lagrange is that they discovered fundamental connections

First the classic theorem of Wilson (of which there are many, many proofs, including one-and-a-half of my own (published in 1967)):

Wilson's theorem (first proved by Lagrange in 1777). For p prime one has (p-1)! = -1 (mod p ).

Note. The converse of Wilson's theorem:

if (n-1)! = -1 (mod n ), then n is prime

is a complete triviality (however, should polynomial time factorial modular computation ever become a reality then that would be a different matter!).

Numerical examples (here I am interested only in demonstration , not in fancy footwork; in short, I want you to see the potential size of the numbers involved).

> p := 37; # a prime, of course
(p-1)!; # the actual value of the factorial
(p-1)! mod p; # the normal remainder
mods((p-1)!, p); # the least absolute remainder

p := 37

371993326789901217467999448150835200000000

36

-1

> p := 39; # NOT a prime
(p-1)!; # the actual value of the factorial
(p-1)! mod p; # the normal remainder
mods((p-1)!, p); # the least absolute remainder

p := 39

523022617466601111760007224100074291200000000

0

0

I had to omit the large output from the (p-1)! following in the html version, as it led to problems:

> p := nextprime(1234); # a prime
# (p-1)!; # the actual value of the factorial
(p-1)! mod p; # the normal remainder
mods((p-1)!, p); # the least absolute remainder

p := 1237

1236

-1

>

Lagrange besides publishing the first proof of Wilson's theorem in 1777, published some important related work: he proved - using Wilson's theorem - important distinctions (discovered by Fermat, who could not provide proofs) between the way in which primes leaving remainders 1 and 3 on division by 4 behaved.

Briefly, Fermat had observed (in equivalent non-congruence language ; congruence notation only came in with Gauss in his monumental Disquisitiones Arithmeticae (1801)) that

Numerical illustrations.

> p := nextprime(1000);
p mod 4;
msolve(x^2 + 1 = 0, p);

p := 1009

1

{x = 540}, {x = 469}

> p := nextprime(2000);
p mod 4;
msolve(x^2 + 1 = 0, p);

p := 2003

3

>

Suffice it to say that Lagrange noted the following (trivially-derived) consequence of Wilson's theorem:

((p-1)/2)!^2 = (-1)^((p+1)/2) (mod p ) (Lagrange congruence)


(you see why, of course? Use
p-r = -r (mod p ), for r = 1, 2, 3, `...`, (p-1)/2 , and...)


In summary, this is what one had :